/*
 * This file is part of Cadmium.
 * Copyright (C) 2007-2010 Xavier Clerc.
 *
 * Cadmium is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Cadmium is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package fr.x9c.cadmium.primitives.cadmiumjdbc;

import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.NClob;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.RowId;
import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;

import fr.x9c.cadmium.kernel.Block;
import fr.x9c.cadmium.kernel.Channel;
import fr.x9c.cadmium.kernel.CodeRunner;
import fr.x9c.cadmium.kernel.Custom;
import fr.x9c.cadmium.kernel.Fail;
import fr.x9c.cadmium.kernel.Primitive;
import fr.x9c.cadmium.kernel.PrimitiveProvider;
import fr.x9c.cadmium.kernel.Value;
import fr.x9c.cadmium.primitives.cadmium.Cadmium;

/**
 * This class provides the primitives related to the <tt>java.sql.ResultSet</tt> class.
 *
 * @author <a href="mailto:cadmium@x9c.fr">Xavier Clerc</a>
 * @version 1.1
 * @since 1.1
 */
@PrimitiveProvider
public final class ResultSets {

    /**
     * No instance of this class.
     */
    private ResultSets() {
    } // end empty constructor

    /**
     * Moves the cursor to a given row number.
     * @param ctxt context
     * @param resultset result set
     * @param row row number
     * @return <tt>true</tt> if the cursor was actually moved to the passed row,
     *         <tt>false</tt> if such a row does not exists
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_absolute(final CodeRunner ctxt,
                                                       final Value resultset,
                                                       final Value row)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.absolute(row.asBlock().asInt32()) ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_absolute(CodeRunner, Value, Value)'

    /**
     * Moves the cursor at the end of the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_after_last(final CodeRunner ctxt,
                                                         final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.afterLast();
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_after_last(CodeRunner, Value)'

    /**
     * Moves the cursor at the begin of the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_before_first(final CodeRunner ctxt,
                                                           final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.beforeFirst();
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_before_first(CodeRunner, Value)'

    /**
     * Cancels the updates made to the current row.
     * @param ctxt context
     * @param resultset result set
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_cancel_row_updates(final CodeRunner ctxt,
                                                                 final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.cancelRowUpdates();
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_cancel_row_updates(CodeRunner, Value)'

    /**
     * Clears the warnings for the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_clear_warnings(final CodeRunner ctxt,
                                                             final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.clearWarnings();
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_clear_warnings(CodeRunner, Value)'

    /**
     * Closes the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_close(final CodeRunner ctxt,
                                                    final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.close();
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_close(CodeRunner, Value)'

    /**
     * Deletes the current row.
     * @param ctxt context
     * @param resultset result set
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_delete_row(final CodeRunner ctxt,
                                                         final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.deleteRow();
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_delete_row(CodeRunner, Value)'

    /**
     * Returns the index of the column having the passed label.
     * @param ctxt context
     * @param resultset result set
     * @param label column label
     * @return the index of the column having the passed label
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_find_column(final CodeRunner ctxt,
                                                          final Value resultset,
                                                          final Value label)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return Value.createFromLong(rs.findColumn(label.asBlock().asString()));
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_find_column(CodeRunner, Value, Value)'

    /**
     * Moves the cursor to the first row.
     * @param ctxt context
     * @param resultset result set
     * @return <tt>true</tt> if the cursor was actually moved to the first row,
     *         <tt>false</tt> if such a row does not exists
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_first(final CodeRunner ctxt,
                                                    final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.first() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_first(CodeRunner, Value)'

    /**
     * Returns the column at the given index as an array value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as an array value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_array_idx(final CodeRunner ctxt,
                                                            final Value resultset,
                                                            final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Array value = rs.getArray(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_array_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as an array value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as an array value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_array_name(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Array value = rs.getArray(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_array_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as an ASCII stream.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as an ASCII stream
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_ascii_stream_idx(final CodeRunner ctxt,
                                                                   final Value resultset,
                                                                   final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final InputStream value = rs.getAsciiStream(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Channel ch = new Channel(value);
                ctxt.getContext().addChannel(ch);
                final Block b = Block.createCustom(Custom.CHANNEL_SIZE,
                                                   Custom.CHANNEL_OPS);
                b.setCustom(ch);
                final Block res  = Block.createBlock(0, Value.createFromBlock(b));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_ascii_stream_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as an ASCII stream.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as an ASCII stream
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_ascii_stream_name(final CodeRunner ctxt,
                                                                    final Value resultset,
                                                                    final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final InputStream value = rs.getAsciiStream(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Channel ch = new Channel(value);
                ctxt.getContext().addChannel(ch);
                final Block b = Block.createCustom(Custom.CHANNEL_SIZE,
                                                   Custom.CHANNEL_OPS);
                b.setCustom(ch);
                final Block res  = Block.createBlock(0, Value.createFromBlock(b));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_ascii_stream_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a big decimal value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a big decimal value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_big_decimal_idx(final CodeRunner ctxt,
                                                                  final Value resultset,
                                                                  final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final BigDecimal value = rs.getBigDecimal(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_big_decimal_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a big decimal value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a big decimal value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_big_decimal_name(final CodeRunner ctxt,
                                                                   final Value resultset,
                                                                   final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final BigDecimal value = rs.getBigDecimal(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_big_decimal_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a binary stream.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a binary stream
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_binary_stream_idx(final CodeRunner ctxt,
                                                                    final Value resultset,
                                                                    final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final InputStream value = rs.getBinaryStream(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Channel ch = new Channel(value);
                ctxt.getContext().addChannel(ch);
                final Block b = Block.createCustom(Custom.CHANNEL_SIZE,
                                                   Custom.CHANNEL_OPS);
                b.setCustom(ch);
                final Block res  = Block.createBlock(0, Value.createFromBlock(b));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_binary_stream_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a binary stream.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a binary stream
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_binary_stream_name(final CodeRunner ctxt,
                                                                     final Value resultset,
                                                                     final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final InputStream value = rs.getBinaryStream(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Channel ch = new Channel(value);
                ctxt.getContext().addChannel(ch);
                final Block b = Block.createCustom(Custom.CHANNEL_SIZE,
                                                   Custom.CHANNEL_OPS);
                b.setCustom(ch);
                final Block res  = Block.createBlock(0, Value.createFromBlock(b));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_binary_stream_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a blob value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a blob value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_blob_idx(final CodeRunner ctxt,
                                                           final Value resultset,
                                                           final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Blob value = rs.getBlob(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_blob_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a blob value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a blob value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_blob_name(final CodeRunner ctxt,
                                                            final Value resultset,
                                                            final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Blob value = rs.getBlob(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_blob_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a boolean value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a boolean value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_boolean_idx(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final boolean value = rs.getBoolean(idx.asLong());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, value ? Value.TRUE : Value.FALSE);
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_boolean_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a boolean value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a boolean value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_boolean_name(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final boolean value = rs.getBoolean(name.asBlock().asString());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, value ? Value.TRUE : Value.FALSE);
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_boolean_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a byte value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a byte value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_byte_idx(final CodeRunner ctxt,
                                                           final Value resultset,
                                                           final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final byte value = rs.getByte(idx.asLong());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromLong(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_byte_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a byte value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a byte value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_byte_name(final CodeRunner ctxt,
                                                            final Value resultset,
                                                            final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final byte value = rs.getByte(name.asBlock().asString());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromLong(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_byte_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a byte array value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a byte array value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_bytes_idx(final CodeRunner ctxt,
                                                            final Value resultset,
                                                            final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final byte[] value = rs.getBytes(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_bytes_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a byte array value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a byte array value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_bytes_name(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final byte[] value = rs.getBytes(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_bytes_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a clob value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a clob value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_clob_idx(final CodeRunner ctxt,
                                                           final Value resultset,
                                                           final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Clob value = rs.getClob(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_clob_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a clob value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a clob value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_clob_name(final CodeRunner ctxt,
                                                            final Value resultset,
                                                            final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Clob value = rs.getClob(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_clob_name(CodeRunner, Value, Value)'

    /**
     * Returns the concurrency mode of the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @return the concurrency mode of the passed result set
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_concurrency(final CodeRunner ctxt,
                                                              final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return Misc.encodeResultSetConcurrency(rs.getConcurrency());
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_concurrency(CodeRunner, Value)'

    /**
     * Returns the cursor name of the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @return the cursor name of the passed result set
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_cursor_name(final CodeRunner ctxt,
                                                              final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Block res = Block.createString(rs.getCursorName());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_cursor_name(CodeRunner, Value)'

    /**
     * Returns the column at the given index as a date value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a date value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_date_idx(final CodeRunner ctxt,
                                                           final Value resultset,
                                                           final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Date value = rs.getDate(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_date_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a date value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a date value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_date_name(final CodeRunner ctxt,
                                                            final Value resultset,
                                                            final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Date value = rs.getDate(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_date_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a double value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a double value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_double_idx(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final double value = rs.getDouble(idx.asLong());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createDouble(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_double_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a double value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a double value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_double_name(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final double value = rs.getDouble(name.asBlock().asString());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createDouble(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_double_name(CodeRunner, Value, Value)'

    /**
     * Returns the fetch direction of the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @return the fetch direction of the passed result set
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_fetch_direction(final CodeRunner ctxt,
                                                                  final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return Misc.encodeResultSetFetchDirection(rs.getFetchDirection());
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_fetch_direction(CodeRunner, Value)'

    /**
     * Returns the fetch size of the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @return the fetch size of the passed result set
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_fetch_size(final CodeRunner ctxt,
                                                             final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(rs.getFetchSize());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_fetch_size(CodeRunner, Value)'

    /**
     * Returns the column at the given index as a float value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a float value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_float_idx(final CodeRunner ctxt,
                                                            final Value resultset,
                                                            final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final float value = rs.getFloat(idx.asLong());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createDouble(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_float_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a float value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a float value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_float_name(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final float value = rs.getFloat(name.asBlock().asString());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createDouble(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_float_name(CodeRunner, Value, Value)'

    /**
     * Returns the holdability of the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @return the holdability of the passed result set
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_holdability(final CodeRunner ctxt,
                                                              final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return Misc.encodeResultSetHoldability(rs.getType());
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_holdability(CodeRunner, Value)'

    /**
     * Returns the column at the given index as an integer value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as an integer value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_int_idx(final CodeRunner ctxt,
                                                          final Value resultset,
                                                          final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final int value = rs.getInt(idx.asLong());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block b = Block.createCustom(Custom.INT_32_SIZE,
                                                   Custom.INT_32_OPS);
                b.setInt32(value);
                final Block res  = Block.createBlock(0, Value.createFromBlock(b));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_int_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as an integer value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as an integer value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_int_name(final CodeRunner ctxt,
                                                           final Value resultset,
                                                           final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final int value = rs.getInt(name.asBlock().asString());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block b = Block.createCustom(Custom.INT_32_SIZE,
                                                   Custom.INT_32_OPS);
                b.setInt32(value);
                final Block res  = Block.createBlock(0, Value.createFromBlock(b));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_int_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a long value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a long value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_long_idx(final CodeRunner ctxt,
                                                           final Value resultset,
                                                           final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final long value = rs.getLong(idx.asLong());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block b = Block.createCustom(Custom.INT_64_SIZE,
                                                   Custom.INT_64_OPS);
                b.setInt64(value);
                final Block res  = Block.createBlock(0, Value.createFromBlock(b));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_long_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a long value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a long value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_long_name(final CodeRunner ctxt,
                                                            final Value resultset,
                                                            final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final long value = rs.getLong(name.asBlock().asString());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block b = Block.createCustom(Custom.INT_64_SIZE,
                                                   Custom.INT_64_OPS);
                b.setInt64(value);
                final Block res  = Block.createBlock(0, Value.createFromBlock(b));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_long_name(CodeRunner, Value, Value)'

    /**
     * Returns the metadata of the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @return the metadata of the passed result set
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_meta_data(final CodeRunner ctxt,
                                                            final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return Cadmium.createObject(rs.getMetaData());
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_meta_data(CodeRunner, Value)'

    /**
     * Returns the column at the given index as a nclob value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a nclob value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_nclob_idx(final CodeRunner ctxt,
                                                            final Value resultset,
                                                            final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final NClob value = rs.getNClob(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_nclob_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a nclob value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a nclob value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_nclob_name(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final NClob value = rs.getNClob(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_nclob_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a nstring value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a nstring value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_nstring_idx(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final String value = rs.getNString(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_nstring_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a nstring value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a nstring value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_nstring_name(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final String value = rs.getNString(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_nstring_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as an object value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as an object value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_object_idx(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Object value = rs.getObject(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_object_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as an object value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as an object value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_object_name(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Object value = rs.getObject(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_object_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a reference value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a reference value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_ref_idx(final CodeRunner ctxt,
                                                          final Value resultset,
                                                          final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Ref value = rs.getRef(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_ref_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a reference value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a reference value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_ref_name(final CodeRunner ctxt,
                                                           final Value resultset,
                                                           final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Ref value = rs.getRef(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_ref_name(CodeRunner, Value, Value)'

    /**
     * Returns the current row number.
     * @param ctxt context
     * @param resultset result set
     * @return the current row number
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_row(final CodeRunner ctxt,
                                                      final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Block res = Block.createCustom(Custom.INT_32_SIZE,
                                                 Custom.INT_32_OPS);
            res.setInt32(rs.getRow());
            return Value.createFromBlock(res);
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_row(CodeRunner, Value)'

    /**
     * Returns the column at the given index as a row id value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a row id value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_row_id_idx(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final RowId value = rs.getRowId(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_row_id_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a row id value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a row id value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_row_id_name(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final RowId value = rs.getRowId(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_row_id_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a short value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a short value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_short_idx(final CodeRunner ctxt,
                                                            final Value resultset,
                                                            final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final short value = rs.getShort(idx.asLong());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromLong(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_short_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a short value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a short value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_short_name(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final short value = rs.getShort(name.asBlock().asString());
            if (rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromLong(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_short_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a SQL XML value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a SQL XML value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_sqlxml_idx(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final SQLXML value = rs.getSQLXML(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_sqlxml_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a SQL XML value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a SQL XML value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_sqlxml_name(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final SQLXML value = rs.getSQLXML(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_sqlxml_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a string value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a string value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_string_idx(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final String value = rs.getString(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_string_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a string value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a string value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_string_name(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final String value = rs.getString(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_string_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a time value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a time value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_time_idx(final CodeRunner ctxt,
                                                           final Value resultset,
                                                           final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Time value = rs.getTime(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_time_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a time value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a time value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_time_name(final CodeRunner ctxt,
                                                            final Value resultset,
                                                            final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Time value = rs.getTime(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_time_name(CodeRunner, Value, Value)'

    /**
     * Returns the column at the given index as a timestamp value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a timestamp value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_timestamp_idx(final CodeRunner ctxt,
                                                                final Value resultset,
                                                                final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Timestamp value = rs.getTimestamp(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_timestamp_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a timestamp value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a timestamp value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_timestamp_name(final CodeRunner ctxt,
                                                                 final Value resultset,
                                                                 final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final Timestamp value = rs.getTimestamp(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_timestamp_name(CodeRunner, Value, Value)'

    /**
     * Returns the type of the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @return the type of the passed result set
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_type(final CodeRunner ctxt,
                                                       final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return Misc.encodeResultSetType(rs.getType());
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_type(CodeRunner, Value)'

    /**
     * Returns the column at the given index as a URL value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @return the column at the given index as a URL value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_url_idx(final CodeRunner ctxt,
                                                          final Value resultset,
                                                          final Value idx)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final URL value = rs.getURL(idx.asLong());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value.toString())));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_url_idx(CodeRunner, Value, Value)'

    /**
     * Returns the column with the given name as a URL value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @return the column with the given name as a URL value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_url_name(final CodeRunner ctxt,
                                                           final Value resultset,
                                                           final Value name)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            final URL value = rs.getURL(name.asBlock().asString());
            if ((value == null) || rs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value.toString())));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_url_name(CodeRunner, Value, Value)'

    /**
     * Returns the list of warnings for the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @return the list of warnings for the passed result set
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_get_warnings(final CodeRunner ctxt,
                                                           final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return Misc.encodeSQLWarnings(rs.getWarnings());
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_get_warnings(CodeRunner, Value)'

    /**
     * Inserts the content of the insert row in the result set, as well as in the
     * underlying database.
     * @param ctxt context
     * @param resultset result set
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_insert_row(final CodeRunner ctxt,
                                                         final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.insertRow();
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_insert_row(CodeRunner, Value)'

    /**
     * Tests whether the cursor is after the last row.
     * @param ctxt context
     * @param resultset result set
     * @return <tt>true</tt> if the cursor is after the last row, <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_is_after_last(final CodeRunner ctxt,
                                                            final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.isAfterLast() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_is_after_last(CodeRunner, Value)'

    /**
     * Tests whether the cursor is before the first row.
     * @param ctxt context
     * @param resultset result set
     * @return <tt>true</tt> if the cursor is before the first row, <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_is_before_first(final CodeRunner ctxt,
                                                              final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.isBeforeFirst() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_is_before_first(CodeRunner, Value)'

    /**
     * Tests whether the cursor is closed.
     * @param ctxt context
     * @param resultset result set
     * @return <tt>true</tt> if the cursor is closed, <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_is_closed(final CodeRunner ctxt,
                                                        final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.isClosed() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_is_closed(CodeRunner, Value)'

    /**
     * Tests whether the cursor is on the first row.
     * @param ctxt context
     * @param resultset result set
     * @return <tt>true</tt> if the cursor is on the first row, <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_is_first(final CodeRunner ctxt,
                                                       final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.isFirst() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_is_first(CodeRunner, Value)'

    /**
     * Tests whether the cursor is on the last row.
     * @param ctxt context
     * @param resultset result set
     * @return <tt>true</tt> if the cursor is on the last row, <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_is_last(final CodeRunner ctxt,
                                                      final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.isLast() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_is_last(CodeRunner, Value)'

    /**
     * Moves the cursor to the last row.
     * @param ctxt context
     * @param resultset result set
     * @return <tt>true</tt> if the cursor was actually moved to the last row,
     *         <tt>false</tt> if such a row does not exists
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_last(final CodeRunner ctxt,
                                                   final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.last() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_last(CodeRunner, Value)'

    /**
     * Moves the cursor to the current row.
     * @param ctxt context
     * @param resultset result set
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_move_to_current_row(final CodeRunner ctxt,
                                                                  final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.moveToCurrentRow();
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_move_to_current_row(CodeRunner, Value)'

    /**
     * Moves the cursor to the insert row.
     * @param ctxt context
     * @param resultset result set
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_move_to_insert_row(final CodeRunner ctxt,
                                                                 final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.moveToInsertRow();
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_move_to_insert_row(CodeRunner, Value)'

    /**
     * Moves the cursor to the next row.
     * @param ctxt context
     * @param resultset result set
     * @return <tt>true</tt> if the cursor was actually moved to the next row,
     *         <tt>false</tt> if such a row does not exists
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_next(final CodeRunner ctxt,
                                                   final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.next() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_next(CodeRunner, Value)'

    /**
     * Moves the cursor to the previous row.
     * @param ctxt context
     * @param resultset result set
     * @return <tt>true</tt> if the cursor was actually moved to the previous row,
     *         <tt>false</tt> if such a row does not exists
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_previous(final CodeRunner ctxt,
                                                       final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.previous() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_previous(CodeRunner, Value)'

    /**
     * Refreshes the row with the database values.
     * @param ctxt context
     * @param resultset result set
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_refresh_row(final CodeRunner ctxt,
                                                          final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.refreshRow();
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_refresh_row(CodeRunner, Value)'

    /**
     * Moves the cursor by a given number of rows.
     * @param ctxt context
     * @param resultset result set
     * @param rows row number
     * @return <tt>true</tt> if the cursor was actually moved by the passed number of rows,
     *         <tt>false</tt> if such a row does not exists
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_relative(final CodeRunner ctxt,
                                                       final Value resultset,
                                                       final Value rows)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.relative(rows.asBlock().asInt32()) ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_relative(CodeRunner, Value, Value)'

    /**
     * Tests whether a row has been deleted.
     * @param ctxt context
     * @param resultset result set
     * @return <tt>true</tt> if a row has been deleted, <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_row_deleted(final CodeRunner ctxt,
                                                          final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.rowDeleted() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_row_deleted(CodeRunner, Value)'

    /**
     * Tests whether a row has been inserted.
     * @param ctxt context
     * @param resultset result set
     * @return <tt>true</tt> if a row has been inserted, <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_row_inserted(final CodeRunner ctxt,
                                                           final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.rowInserted() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_row_inserted(CodeRunner, Value)'

    /**
     * Tests whether a row has been updated.
     * @param ctxt context
     * @param resultset result set
     * @return <tt>true</tt> if a row has been updated, <tt>false</tt> otherwise
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_row_updated(final CodeRunner ctxt,
                                                          final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            return rs.rowUpdated() ? Value.TRUE : Value.FALSE;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_row_updated(CodeRunner, Value)'

    /**
     * Sets the fetch direction of the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @param direction fetch direction
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_set_fetch_direction(final CodeRunner ctxt,
                                                                  final Value resultset,
                                                                  final Value direction)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.setFetchDirection(Misc.decodeResultSetFetchDirection(direction));
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_set_fetch_direction(CodeRunner, Value, Value)'

    /**
     * Sets the fetch size of the passed result set.
     * @param ctxt context
     * @param resultset result set
     * @param size fetch size
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_set_fetch_size(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value size)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.setFetchSize(size.asBlock().asInt32());
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_set_fetch_size(CodeRunner, Value, Value)'

    /**
     * Sets the column at the given index to an array value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_array_idx(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value idx,
                                                               final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateArray(idx.asLong(),
                               (Array) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_array_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to an array value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_array_name(final CodeRunner ctxt,
                                                                final Value resultset,
                                                                final Value name,
                                                                final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateArray(name.asBlock().asString(),
                               (Array) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_array_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to an ASCII stream.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_ascii_stream_idx(final CodeRunner ctxt,
                                                                      final Value resultset,
                                                                      final Value idx,
                                                                      final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                rs.updateAsciiStream(idx.asLong(), ch.asInputStream());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_ascii_stream_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to an ASCII stream.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_ascii_stream_name(final CodeRunner ctxt,
                                                                       final Value resultset,
                                                                       final Value name,
                                                                       final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                rs.updateAsciiStream(name.asBlock().asString(), ch.asInputStream());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_ascii_stream_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to an ASCII stream.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @param length stream length
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_ascii_stream_length_idx(final CodeRunner ctxt,
                                                                             final Value resultset,
                                                                             final Value idx,
                                                                             final Value x,
                                                                             final Value length)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                rs.updateAsciiStream(idx.asLong(), ch.asInputStream(),
                                     length.asBlock().asInt32());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_ascii_stream_length_idx(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the column with the given name to an ASCII stream.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @param length stream length
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_ascii_stream_length_name(final CodeRunner ctxt,
                                                                              final Value resultset,
                                                                              final Value name,
                                                                              final Value x,
                                                                              final Value length)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                rs.updateAsciiStream(name.asBlock().asString(), ch.asInputStream(),
                                     length.asBlock().asInt32());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_ascii_stream_length_name(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the column at the given index to an ASCII stream.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @param length stream length
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_ascii_stream_length64_idx(final CodeRunner ctxt,
                                                                               final Value resultset,
                                                                               final Value idx,
                                                                               final Value x,
                                                                               final Value length)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                rs.updateAsciiStream(idx.asLong(), ch.asInputStream(),
                                     length.asBlock().asInt64());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_ascii_stream_length64_idx(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the column with the given name to an ASCII stream.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @param length stream length
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_ascii_stream_length64_name(final CodeRunner ctxt,
                                                                                final Value resultset,
                                                                                final Value name,
                                                                                final Value x,
                                                                                final Value length)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                rs.updateAsciiStream(name.asBlock().asString(), ch.asInputStream(),
                                     length.asBlock().asInt64());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_ascii_stream_length64_name(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the column at the given index to a big decimal value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_big_decimal_idx(final CodeRunner ctxt,
                                                                     final Value resultset,
                                                                     final Value idx,
                                                                     final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateBigDecimal(idx.asLong(),
                                    (BigDecimal) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_big_decimal_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a big decimal value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_big_decimal_name(final CodeRunner ctxt,
                                                                      final Value resultset,
                                                                      final Value name,
                                                                      final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateBigDecimal(name.asBlock().asString(),
                                    (BigDecimal) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_big_decimal_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a binary stream.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_binary_stream_idx(final CodeRunner ctxt,
                                                                       final Value resultset,
                                                                       final Value idx,
                                                                       final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                rs.updateBinaryStream(idx.asLong(), ch.asInputStream());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_binary_stream_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a binary stream.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_binary_stream_name(final CodeRunner ctxt,
                                                                        final Value resultset,
                                                                        final Value name,
                                                                        final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                rs.updateBinaryStream(name.asBlock().asString(), ch.asInputStream());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_binary_stream_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a binary stream.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @param length stream length
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_binary_stream_length_idx(final CodeRunner ctxt,
                                                                              final Value resultset,
                                                                              final Value idx,
                                                                              final Value x,
                                                                              final Value length)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                rs.updateBinaryStream(idx.asLong(), ch.asInputStream(),
                                      length.asBlock().asInt32());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_binary_stream_length_idx(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the column with the given name to a binary stream.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @param length stream length
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_binary_stream_length_name(final CodeRunner ctxt,
                                                                               final Value resultset,
                                                                               final Value name,
                                                                               final Value x,
                                                                               final Value length)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                rs.updateBinaryStream(name.asBlock().asString(), ch.asInputStream(),
                                      length.asBlock().asInt32());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_binary_stream_length_name(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the column at the given index to a binary stream.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @param length stream length
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_binary_stream_length64_idx(final CodeRunner ctxt,
                                                                                final Value resultset,
                                                                                final Value idx,
                                                                                final Value x,
                                                                                final Value length)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                rs.updateBinaryStream(idx.asLong(), ch.asInputStream(),
                                      length.asBlock().asInt64());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_binary_stream_length64_idx(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the column with the given name to a binary stream.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @param length stream length
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_binary_stream_length64_name(final CodeRunner ctxt,
                                                                                 final Value resultset,
                                                                                 final Value name,
                                                                                 final Value x,
                                                                                 final Value length)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                rs.updateBinaryStream(name.asBlock().asString(), ch.asInputStream(),
                                      length.asBlock().asInt64());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_binary_stream_length64_name(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the column at the given index to a blob value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_blob_idx(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value idx,
                                                              final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateBlob(idx.asLong(),
                              (Blob) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_blob_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a blob value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_blob_name(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value name,
                                                               final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateBlob(name.asBlock().asString(),
                              (Blob) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_blob_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a boolean value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_boolean_idx(final CodeRunner ctxt,
                                                                 final Value resultset,
                                                                 final Value idx,
                                                                 final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateBoolean(idx.asLong(),
                                 x.asBlock().get(0) == Value.TRUE);
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_boolean_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a boolean value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_boolean_name(final CodeRunner ctxt,
                                                                  final Value resultset,
                                                                  final Value name,
                                                                  final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateBoolean(name.asBlock().asString(),
                                 x.asBlock().get(0) == Value.TRUE);
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_boolean_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a byte value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_byte_idx(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value idx,
                                                              final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateByte(idx.asLong(), (byte) x.asBlock().get(0).asLong());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_byte_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a byte value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_byte_name(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value name,
                                                               final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateByte(name.asBlock().asString(), (byte) x.asBlock().get(0).asLong());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_byte_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a byte array value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_bytes_idx(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value idx,
                                                               final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateBytes(idx.asLong(), x.asBlock().get(0).asBlock().getBytes());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_bytes_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a byte array value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_bytes_name(final CodeRunner ctxt,
                                                                final Value resultset,
                                                                final Value name,
                                                                final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateBytes(name.asBlock().asString(), x.asBlock().get(0).asBlock().getBytes());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_bytes_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a clob value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_clob_idx(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value idx,
                                                              final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateClob(idx.asLong(),
                              (Clob) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_clob_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a clob value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_clob_name(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value name,
                                                               final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateClob(name.asBlock().asString(),
                              (Clob) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_clob_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a date value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_date_idx(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value idx,
                                                              final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateDate(idx.asLong(),
                              (Date) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_date_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a date value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_date_name(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value name,
                                                               final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateDate(name.asBlock().asString(),
                              (Date) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_date_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a double value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_double_idx(final CodeRunner ctxt,
                                                                final Value resultset,
                                                                final Value idx,
                                                                final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateDouble(idx.asLong(),
                                x.asBlock().get(0).asBlock().asDouble());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_double_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a double value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_double_name(final CodeRunner ctxt,
                                                                 final Value resultset,
                                                                 final Value name,
                                                                 final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateDouble(name.asBlock().asString(),
                                x.asBlock().get(0).asBlock().asDouble());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_double_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a float value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_float_idx(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value idx,
                                                               final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateFloat(idx.asLong(),
                               (float) x.asBlock().get(0).asBlock().asDouble());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_float_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a float value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_float_name(final CodeRunner ctxt,
                                                                final Value resultset,
                                                                final Value name,
                                                                final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateFloat(name.asBlock().asString(),
                               (float) x.asBlock().get(0).asBlock().asDouble());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_float_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to an int value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_int_idx(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value idx,
                                                             final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateInt(idx.asLong(),
                             x.asBlock().get(0).asBlock().asInt32());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_int_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to an int value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_int_name(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value name,
                                                              final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateInt(name.asBlock().asString(),
                             x.asBlock().get(0).asBlock().asInt32());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_int_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a long value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_long_idx(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value idx,
                                                              final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateLong(idx.asLong(),
                              x.asBlock().get(0).asBlock().asInt64());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_long_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a long value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_long_name(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value name,
                                                               final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateLong(name.asBlock().asString(),
                              x.asBlock().get(0).asBlock().asInt64());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_long_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a nclob value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_nclob_idx(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value idx,
                                                               final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateNClob(idx.asLong(),
                               (NClob) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_nclob_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a nclob value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_nclob_name(final CodeRunner ctxt,
                                                                final Value resultset,
                                                                final Value name,
                                                                final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateNClob(name.asBlock().asString(),
                               (NClob) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_nclob_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a nstring value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_nstring_idx(final CodeRunner ctxt,
                                                                 final Value resultset,
                                                                 final Value idx,
                                                                 final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateNString(idx.asLong(),
                                 x.asBlock().get(0).asBlock().asString());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_nstring_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a nstring value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_nstring_name(final CodeRunner ctxt,
                                                                  final Value resultset,
                                                                  final Value name,
                                                                  final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateNString(name.asBlock().asString(),
                                 x.asBlock().get(0).asBlock().asString());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_nstring_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to an object value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_object_idx(final CodeRunner ctxt,
                                                                final Value resultset,
                                                                final Value idx,
                                                                final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateObject(idx.asLong(),
                                x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_object_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to an object value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_object_name(final CodeRunner ctxt,
                                                                 final Value resultset,
                                                                 final Value name,
                                                                 final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateObject(name.asBlock().asString(),
                                x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_object_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to an object value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @param scale scale or length the passed object value should be converted to
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_object_scale_idx(final CodeRunner ctxt,
                                                                      final Value resultset,
                                                                      final Value idx,
                                                                      final Value x,
                                                                      final Value scale)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateObject(idx.asLong(),
                                x.asBlock().get(0).asBlock().asCustom(),
                                scale.asLong());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_object_scale_idx(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the column with the given name to an object value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @param scale scale or length the passed object value should be converted to
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_object_scale_name(final CodeRunner ctxt,
                                                                       final Value resultset,
                                                                       final Value name,
                                                                       final Value x,
                                                                       final Value scale)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateObject(name.asBlock().asString(),
                                x.asBlock().get(0).asBlock().asCustom(),
                                scale.asLong());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_object_scale_name(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the column at the given index to a reference value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_ref_idx(final CodeRunner ctxt,
                                                             final Value resultset,
                                                             final Value idx,
                                                             final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateRef(idx.asLong(),
                             (Ref) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_ref_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a reference value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_ref_name(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value name,
                                                              final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateRef(name.asBlock().asString(),
                             (Ref) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_ref_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a row id value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_row_id_idx(final CodeRunner ctxt,
                                                                final Value resultset,
                                                                final Value idx,
                                                                final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateRowId(idx.asLong(),
                               (RowId) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_row_id_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a row id value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_row_id_name(final CodeRunner ctxt,
                                                                 final Value resultset,
                                                                 final Value name,
                                                                 final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateRowId(name.asBlock().asString(),
                               (RowId) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_row_id_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a short value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_short_idx(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value idx,
                                                               final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateShort(idx.asLong(),
                               (short) x.asBlock().get(0).asLong());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_short_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a short value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_short_name(final CodeRunner ctxt,
                                                                final Value resultset,
                                                                final Value name,
                                                                final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateShort(name.asBlock().asString(),
                               (short) x.asBlock().get(0).asLong());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_short_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a SQL XML value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_sqlxml_idx(final CodeRunner ctxt,
                                                                final Value resultset,
                                                                final Value idx,
                                                                final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateSQLXML(idx.asLong(),
                                (SQLXML) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_sqlxml_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a SQL XML value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_sqlxml_name(final CodeRunner ctxt,
                                                                 final Value resultset,
                                                                 final Value name,
                                                                 final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateSQLXML(name.asBlock().asString(),
                                (SQLXML) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_sqlxml_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a string value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_string_idx(final CodeRunner ctxt,
                                                                final Value resultset,
                                                                final Value idx,
                                                                final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateString(idx.asLong(),
                                x.asBlock().get(0).asBlock().asString());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_string_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a string value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_string_name(final CodeRunner ctxt,
                                                                 final Value resultset,
                                                                 final Value name,
                                                                 final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateString(name.asBlock().asString(),
                                x.asBlock().get(0).asBlock().asString());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_string_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a time value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_time_idx(final CodeRunner ctxt,
                                                              final Value resultset,
                                                              final Value idx,
                                                              final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateTime(idx.asLong(),
                              (Time) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_time_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a time value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_time_name(final CodeRunner ctxt,
                                                               final Value resultset,
                                                               final Value name,
                                                               final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateTime(name.asBlock().asString(),
                              (Time) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_time_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column at the given index to a timestamp value.
     * @param ctxt context
     * @param resultset result set
     * @param idx column index
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_timestamp_idx(final CodeRunner ctxt,
                                                                   final Value resultset,
                                                                   final Value idx,
                                                                   final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateTimestamp(idx.asLong(),
                                   (Timestamp) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(idx.asLong());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_timestamp_idx(CodeRunner, Value, Value, Value)'

    /**
     * Sets the column with the given name to a timestamp value.
     * @param ctxt context
     * @param resultset result set
     * @param name column name
     * @param x column value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_timestamp_name(final CodeRunner ctxt,
                                                                    final Value resultset,
                                                                    final Value name,
                                                                    final Value x)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            if (x.isBlock()) {
                rs.updateTimestamp(name.asBlock().asString(),
                                   (Timestamp) x.asBlock().get(0).asBlock().asCustom());
            } else {
                rs.updateNull(name.asBlock().asString());
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_timestamp_name(CodeRunner, Value, Value, Value)'

    /**
     * Actually updates the database after some modification has been made
     * to the current or inserted row.
     * @param ctxt context
     * @param resultset result set
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_resultset_update_row(final CodeRunner ctxt,
                                                         final Value resultset)
        throws Fail.Exception {
        try {
            final ResultSet rs = (ResultSet) resultset.asBlock().asCustom();
            rs.updateRow();
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_resultset_update_row(CodeRunner, Value)'

} // end class 'ResultSets'
